home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / macps < prev    next >
Encoding:
Internet Message Format  |  1991-12-13  |  41.3 KB

  1. Subject: v25i030: macps - utilities to help print Apple "LaserPrep" files
  2. Newsgroups: comp.sources.unix
  3. Approved: vixie@pa.dec.com
  4.  
  5. Submitted-By: Ed Moy <edmoy@violet.berkeley.edu>
  6. Posting-Number: Volume 25, Issue 30
  7. Archive-Name: macps
  8.  
  9. Macps is a Unix program that takes an uploaded PostScript file created
  10. on a Macintosh (by typing Command-F at the LaserWriter dialog box; see
  11. macps.1 for more details) and includes an appropriately modified
  12. LaserPrep file so that the result can be sent to a PostScript printer
  13. X>From Unix.  The LaserPrep file contains macros used by the PostScript
  14. generator on the Macintosh.
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 1 (of 1)."
  23. # Contents:  Installation MANIFEST Makefile ReadMe macaux.c macps.1
  24. #   macps.c macps.config prepfix.1 prepfix.c str.h ucbwhich.c
  25. #   ucbwhich.h
  26. # Wrapped by vixie@cognition.pa.dec.com on Fri Dec 13 14:53:21 1991
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'Installation' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'Installation'\"
  30. else
  31. echo shar: Extracting \"'Installation'\" \(3485 characters\)
  32. sed "s/^X//" >'Installation' <<'END_OF_FILE'
  33. Installation Instructions (SCCSid = "@(#)Installation    2.2 10/24/89")
  34. X
  35. X1) Look at the Makefile.  There are three CFLAGS options that you can
  36. use.  Setting SYSV should allow macps and prepfix to compile on System
  37. V machines (I've only tried it under A/UX).  Setting CONFIGDIR will
  38. cause macps to look for macps.config in that directory.  Setting SAVE
  39. will cause macps to enclose the entire print job is a PostScript
  40. save/restore context.  Normally you don't need SAVE, since most
  41. spooling software will automatically do an EOF between print jobs, which
  42. effectively does a restore of memory for you, but some spooling
  43. software does require the save/restore.  Note that defining SAVE will
  44. cause printing to fail on a NeXT laser printer, while it is harmless on
  45. most other systems.
  46. X
  47. The options will look something like:
  48. X
  49. CFLAGS = -O -DSYSV -DCONFIGDIR=\"/usr/new/lib\" -DSAVE
  50. X
  51. if you defined all the options.
  52. X
  53. X2) Type "make".  If all goes well, macps and prepfix will be created.
  54. X
  55. X3) To create the unprocessed LaserPrep file on the Mac, as well as
  56. creating the raw PostScript files that you want to print, make sure
  57. that either you're not running MultiFinder, or if you are, go to the
  58. Chooser under the Apple menu, click on the LaserWriter icon and then
  59. turn off Background Printing.
  60. X
  61. X4) For each version of LaserPrep on the Mac that you want to include,
  62. install that version in the System Folder.  Then, open an empty
  63. document in some simple application (one that doesn't have its
  64. own ProcSet to download).  Choose Print from the File menu and the
  65. LaserWriter print dialog will appear.  Click on the OK button and
  66. IMMEDIATELY press and hold Command-K.  When a dialog box appears
  67. telling you that it is creating a PostScript file, you can release
  68. Command-K.  The unprocessed LaserPrep file will usually be found in one
  69. of three places, in the System Folder, in the same folder as the
  70. application or at the top level of the disk.
  71. X
  72. X5) Upload the PostScript file(s) to Unix, using some file transfer
  73. program like MacTerminal, Versaterm, Red Ryder, MacKermit or NCSA
  74. Telnet (if your file transfer program feels left out, feel free to add
  75. it to your list).
  76. X
  77. X6) Run prepfix on each unprocessed file, diverting the standard output
  78. to an appropriataly named file (like LaserPrep5.2).  If you want to
  79. allow bit smoothing on a non-Apple PostScript printer, specify the -l
  80. option to prepfix (you can specify as many printer names as you want,
  81. each with a separate -l flag).  If you aren't sure the your printer can
  82. do smoothing, you can try it and see if it works (if it doesn't, you
  83. can always re-run prepfix on the unprocessed file(s), leaving off the
  84. printer that doesn't work).  If you don't know the product name for you
  85. printer, you can use the following PostScript code to print it:
  86. X
  87. X%!
  88. X/in {72 mul} def
  89. X/Courier findfont 18 scalefont setfont
  90. X1 in 8 in moveto
  91. statusdict /product get show
  92. showpage
  93. X
  94. X7) Put the modified LaserPrep file(s) in some directory and modify the
  95. macps.config file to point to these LaserPrep files.  Then put the
  96. macps.config file in a "lib" subdirectory to where you install macps
  97. X(or in the directory CONFIGDIR if you used that option).
  98. X
  99. X8) Now when you want to print something, do the same thing as in step 4
  100. above with the LaserWriter print dialog, except press and hold
  101. Command-F (this cause LaserPrep not to be included in the PostScript
  102. file).
  103. X
  104. X9) Upload the PostScript file and run macps on it, sending the output
  105. to your printer, as in:
  106. X
  107. X    % macps psfile | lpr
  108. END_OF_FILE
  109. if test 3485 -ne `wc -c <'Installation'`; then
  110.     echo shar: \"'Installation'\" unpacked with wrong size!
  111. fi
  112. # end of 'Installation'
  113. fi
  114. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  115.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  116. else
  117. echo shar: Extracting \"'MANIFEST'\" \(517 characters\)
  118. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  119. X   File Name        Archive #    Description
  120. X-----------------------------------------------------------
  121. X Installation               1    
  122. X MANIFEST                   1    This shipping list
  123. X Makefile                   1    
  124. X ReadMe                     1    
  125. X macaux.c                   1    
  126. X macps.1                    1    
  127. X macps.c                    1    
  128. X macps.config               1    
  129. X prepfix.1                  1    
  130. X prepfix.c                  1    
  131. X str.h                      1    
  132. X ucbwhich.c                 1    
  133. X ucbwhich.h                 1    
  134. END_OF_FILE
  135. if test 517 -ne `wc -c <'MANIFEST'`; then
  136.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  137. fi
  138. # end of 'MANIFEST'
  139. fi
  140. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  141.   echo shar: Will not clobber existing file \"'Makefile'\"
  142. else
  143. echo shar: Extracting \"'Makefile'\" \(1338 characters\)
  144. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  145. X# Copyright (c) 1988, The Regents of the University of California.
  146. X# Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  147. X# Information Systems and Technology.
  148. X#
  149. X# Permission is granted to any individual or institution to use, copy,
  150. X# or redistribute this software so long as it is not sold for profit,
  151. X# provided that this notice and the original copyright notices are
  152. X# retained.  The University of California makes no representations about the
  153. X# suitability of this software for any purpose.  It is provided "as is"
  154. X# without express or implied warranty.
  155. X#
  156. X# SCCSid = "@(#)Makefile    2.2 10/24/89"
  157. X#
  158. X# For System V, include -DSYSV in CFLAGS below.
  159. X# To specify a fixed path for macps.config, include -DCONFIGDIR=\"path\"
  160. X# in CFLAGS below (path is the full pathname of the directory).
  161. X# To do save/restore context, include -DSAVE in CFLAGS below.
  162. X#
  163. CFLAGS = -O
  164. MACPS = macps.o macaux.o ucbwhich.o
  165. PREPFIX = prepfix.o macaux.o
  166. DESTPATH = /usr/local
  167. X
  168. all : macps prepfix
  169. X
  170. install :
  171. X    install -c macps $(DESTPATH)/bin/macps
  172. X    install -c macps.1 $(DESTPATH)/man/man1/macps.1
  173. X    install -c prepfix $(DESTPATH)/bin/prepfix
  174. X    install -c prepfix.1 $(DESTPATH)/man/man1/prepfix.1
  175. X
  176. macps : $(MACPS)
  177. X    cc -o macps $(CFLAGS) $(MACPS)
  178. X
  179. prepfix : $(PREPFIX)
  180. X    cc -o prepfix $(CFLAGS) $(PREPFIX)
  181. X
  182. clean :
  183. X    /bin/rm -f *.o macps prepfix
  184. END_OF_FILE
  185. if test 1338 -ne `wc -c <'Makefile'`; then
  186.     echo shar: \"'Makefile'\" unpacked with wrong size!
  187. fi
  188. # end of 'Makefile'
  189. fi
  190. if test -f 'ReadMe' -a "${1}" != "-c" ; then 
  191.   echo shar: Will not clobber existing file \"'ReadMe'\"
  192. else
  193. echo shar: Extracting \"'ReadMe'\" \(4682 characters\)
  194. sed "s/^X//" >'ReadMe' <<'END_OF_FILE'
  195. COPYRIGHT NOTICE (SCCSid = "@(#)ReadMe    2.2 10/24/89")
  196. X
  197. Copyright (c) 1988, The Regents of the University of California.
  198. XEdward Moy, Workstation Software Support Group, Workstation Support
  199. Serices, Information Systems and Technology.
  200. X
  201. Permission is granted to any individual or institution to use, copy, or
  202. redistribute this software so long as it is not sold for profit,
  203. provided that this notice and the original copyright notices are
  204. retained.  The University of California makes no representations about
  205. the suitability of this software for any purpose.  It is provided "as
  206. is" without express or implied warranty.
  207. X
  208. WHAT IS MACPS?
  209. X
  210. Macps is a Unix program that takes an uploaded PostScript file created
  211. on a Macintosh (by typing Command-F at the LaserWriter dialog box; see
  212. macps.1 for more details) and includes an appropriately modified
  213. LaserPrep file so that the result can be sent to a PostScript printer
  214. X>From Unix.  The LaserPrep file contains macros used by the PostScript
  215. generator on the Macintosh.
  216. X
  217. WHY IS MACPS NEEDED?
  218. X
  219. This is how Mac printing works.  When a Mac talks to a LaserWriter, it
  220. asks if the LaserWriter has had a LaserPrep file downloaded to it.  A
  221. LaserWriter that is first powered up, has no such LaserPrep file, and
  222. so the Mac downloads it and makes the LaserPrep file resident in
  223. memory.  Then the actual print file is sent to the LaserWriter.
  224. Subsequent print requests need not download the LaserPrep file, unless
  225. it is a different version.
  226. X
  227. Since a LaserWriter connected to a Unix system usually does things
  228. other than Mac printing, it is unwise to make LaserPrep files resident
  229. in memory so that other PostScript jobs have less memory to work with.
  230. What prepfix does is to modify a LaserPrep file so that, among other
  231. things, it does not make itself resident in memory.  Thus, the
  232. LaserPrep file must be downloaded for each Mac print job.  This is the
  233. function of macps, to automatically append the appropriate LaserPrep
  234. file.
  235. X
  236. WHICH VERSION OF THE LASERPREP WILL BE USED?
  237. X
  238. Macps interprets the %%IncludeProcSet directive found in the PostScript
  239. generated by LaserWriter driver 4.0 and greater.  It takes the ProcSet
  240. id and looks it up in a file "macps.config", to get the pathname of the
  241. prep file, and thus macps can convert PostScript generated by different
  242. versions of the LaserWriter driver.
  243. X
  244. HOW ARE THE LASERPREP FILES GENERATED?
  245. X
  246. Since the Apple LaserPrep files are copyrighted, I've included a
  247. program, prepfix, that reads version 4.0 and up LaserPrep files, and
  248. edits them so that they are compatible with Unix, and are even
  249. electronically mailable (See prepfix.1 for more details).
  250. X
  251. WHERE IS THE MACPS.CONFIG FILE LOCATED?
  252. X
  253. Macps has some special code that is able to figure out from which
  254. directory it was called from.  It will then look in a "lib" subdiretory
  255. for the macps.config file.
  256. X
  257. WHAT ABOUT BIT-SMOOTHING ON NON-LASERWRITER PRINTERS?
  258. X
  259. XFor PostScript printers using Motorola 680x0 processors and Adobe
  260. PostScript firmware other than LaserWriters, there is an option that
  261. will allow these printers to do bit-smoothing, just like LaserWriters.
  262. X
  263. CHANGES IN VERSION 2.2
  264. X
  265. Version 2.2 of prepfix now supports LaserPrep 6.0.  The PostScript
  266. save/restore context is now a compile-time option, since it caused
  267. printing to fail on a NeXT printer (though it was harmless on most
  268. other printers).  This save/restore is now more intelligent about
  269. clearing the stacks.
  270. X
  271. CHANGES IN VERSION 2.1
  272. X
  273. Version 2.1 of prepfix uses a safer method for turning on bit-smoothing
  274. for non-Apple printers.  This should get around some of the problems
  275. people have been having with specialized macros in the LaserPreps that
  276. are Apple printer specific.  The -l and -p options in version 1.1 have
  277. been replaced with the single -l option, and the limit on the number
  278. of printers you can specify has been removed.
  279. X
  280. Also, prepfix removes some other various macros that cause
  281. unpredictable problems, and a problem with Apple LaserWriter II/NTs
  282. X(but not other Apple printers).
  283. X
  284. Version 2.1 macps has several new options.  The -c option allow you to
  285. specify the number of copies to generate (overriding any multiple copy
  286. option that was specified on the Macintosh).  The -d option allows an
  287. alternate directory to look for the macps.config file.  Finally, the -r
  288. X(raw) option suppresses the conversion of 8-bit binary into ASCII, and
  289. is useful for some graphics programs that manipulate gray-scale images,
  290. and produce 8-bit binary PostScript output.
  291. X
  292. Macps will even work with a NeXT laser printer, but (at least the 0.8
  293. version of the operating system) will not do bit smoothing.  Beware,
  294. though, that if you print Macintosh patterns at 400 dpi, they will
  295. look funny.
  296. END_OF_FILE
  297. if test 4682 -ne `wc -c <'ReadMe'`; then
  298.     echo shar: \"'ReadMe'\" unpacked with wrong size!
  299. fi
  300. # end of 'ReadMe'
  301. fi
  302. if test -f 'macaux.c' -a "${1}" != "-c" ; then 
  303.   echo shar: Will not clobber existing file \"'macaux.c'\"
  304. else
  305. echo shar: Extracting \"'macaux.c'\" \(3585 characters\)
  306. sed "s/^X//" >'macaux.c' <<'END_OF_FILE'
  307. X/*
  308. X * Copyright (c) 1988, The Regents of the University of California.
  309. X * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  310. X * Information Systems and Technology.
  311. X *
  312. X * Permission is granted to any individual or institution to use, copy,
  313. X * or redistribute this software so long as it is not sold for profit,
  314. X * provided that this notice and the original copyright notices are
  315. X * retained.  The University of California makes no representations about the
  316. X * suitability of this software for any purpose.  It is provided "as is"
  317. X * without express or implied warranty.
  318. X */
  319. X
  320. X#ifndef lint
  321. static char *SCCSid = "@(#)macaux.c    2.2 10/24/89";
  322. X#endif lint
  323. X
  324. X#include <ctype.h>
  325. X#include <stdio.h>
  326. X#include "str.h"
  327. X
  328. X#define    FALSE        0
  329. X#define    TRUE        1
  330. X
  331. extern char *myname;
  332. int rawmode = FALSE;
  333. X
  334. STR *
  335. STRalloc()
  336. X{
  337. X    register STR *str;
  338. X    char *malloc();
  339. X
  340. X    if((str = (STR *)malloc(sizeof(STR))) == NULL ||
  341. X     (str->bufptr = (unsigned char *)malloc(STRSIZE)) == NULL) {
  342. X        fprintf(stderr, "%s: STRalloc: Out of memory\n", myname);
  343. X        exit(1);
  344. X    }
  345. X    str->curendptr = str->bufptr;
  346. X    str->realendptr = str->bufptr + STRSIZE;
  347. X    return(str);
  348. X}
  349. X
  350. STRfree(str)
  351. STR *str;
  352. X{
  353. X    free((char *)str->bufptr);
  354. X    free((char *)str);
  355. X}
  356. X
  357. STRexpand(str)
  358. register STR *str;
  359. X{
  360. X    register int curend, realend;
  361. X    char *realloc();
  362. X
  363. X    curend = str->curendptr - str->bufptr;
  364. X    realend = (str->realendptr - str->bufptr) + STRSIZEDELTA;
  365. X    if((str->bufptr = (unsigned char *)realloc((char *)str->bufptr,
  366. X     realend)) == NULL) {
  367. X        fprintf(stderr, "%s: STRexpand: Out of memory\n", myname);
  368. X        exit(1);
  369. X    }
  370. X    str->curendptr = str->bufptr + curend;
  371. X    str->realendptr = str->bufptr + realend;
  372. X}
  373. X
  374. STRgets(str, fp)
  375. register STR *str;
  376. register FILE *fp;
  377. X{
  378. X    register int c;
  379. X
  380. X    str->curendptr = str->bufptr;
  381. X    for( ; ; ) {
  382. X        if((c = getc(fp)) == EOF)
  383. X            return(str->curendptr > str->bufptr);
  384. X        if(str->curendptr >= str->realendptr)
  385. X            STRexpand(str);
  386. X        *str->curendptr++ = c;
  387. X        if(c == '\n' || c == '\r')
  388. X            return(TRUE);
  389. X    }
  390. X}
  391. X
  392. STRputsptr(str, cp, fp)
  393. register STR *str;
  394. register unsigned char *cp;
  395. register FILE *fp;
  396. X{
  397. X    if(rawmode) {
  398. X        for( ; cp < str->curendptr ; cp++)
  399. X            putc(*cp, fp);
  400. X        return;
  401. X    }
  402. X    for( ; cp < str->curendptr ; cp++) {
  403. X        if(!isascii(*cp))
  404. X            fprintf(fp, "\\%03o", *cp);
  405. X        else if(isprint(*cp))
  406. X            putc(*cp, fp);
  407. X        else {
  408. X            switch(*cp) {
  409. X             case '\n':
  410. X             case '\r':
  411. X                putc('\n', fp);
  412. X                continue;
  413. X             case '\t':
  414. X                putc('\t', fp);
  415. X                continue;
  416. X             default:
  417. X                fprintf(fp, "\\%03o", *str);
  418. X                continue;
  419. X            }
  420. X        }
  421. X    }
  422. X}
  423. X
  424. STRcompareptr(str, cp, sp)
  425. register STR *str;
  426. register unsigned char *cp, *sp;
  427. X{
  428. X    register int comp;
  429. X
  430. X    for( ; ; ) {
  431. X        if(*sp == 0)
  432. X            return(cp >= str->curendptr ? 0 : 1);
  433. X        if(cp >= str->curendptr)
  434. X            return(-1);
  435. X        if(*sp == '\n') {
  436. X            if(*cp != '\n' && *cp != '\r')
  437. X                return((int)*cp - (int)*sp);
  438. X        } else if((comp = (int)*cp - (int)*sp) != 0)
  439. X            return(comp);
  440. X        cp++;
  441. X        sp++;
  442. X    }
  443. X}
  444. X
  445. STRheadcmpptr(str, cp, sp)
  446. register STR *str;
  447. register unsigned char *cp, *sp;
  448. X{
  449. X    register int comp;
  450. X
  451. X    for( ; ; ) {
  452. X        if(*sp == 0)
  453. X            return(0);
  454. X        if(cp >= str->curendptr)
  455. X            return(-1);
  456. X        if(*sp == '\n') {
  457. X            if(*cp != '\n' && *cp != '\r')
  458. X                return((int)*cp - (int)*sp);
  459. X        } else if((comp = (int)*cp - (int)*sp) != 0)
  460. X            return(comp);
  461. X        cp++;
  462. X        sp++;
  463. X    }
  464. X}
  465. X
  466. unsigned char *
  467. STRmatch(str, sp)
  468. register STR *str;
  469. register unsigned char *sp;
  470. X{
  471. X    register unsigned char *mp, *last;
  472. X    register int firstchar;
  473. X
  474. X    firstchar = *sp;
  475. X    last = str->curendptr - strlen(sp);
  476. X    mp = str->bufptr;
  477. X    while(mp <= last) {
  478. X        if(*mp == firstchar && STRheadcmpptr(str, mp, sp) == 0)
  479. X            return(mp);
  480. X        mp++;
  481. X    }
  482. X    return(NULL);
  483. X}
  484. END_OF_FILE
  485. if test 3585 -ne `wc -c <'macaux.c'`; then
  486.     echo shar: \"'macaux.c'\" unpacked with wrong size!
  487. fi
  488. # end of 'macaux.c'
  489. fi
  490. if test -f 'macps.1' -a "${1}" != "-c" ; then 
  491.   echo shar: Will not clobber existing file \"'macps.1'\"
  492. else
  493. echo shar: Extracting \"'macps.1'\" \(2592 characters\)
  494. sed "s/^X//" >'macps.1' <<'END_OF_FILE'
  495. X.\" SCCSid = "@(#)macps.1    2.2 10/24/89"
  496. X.TH MACPS 1 "24 Oct 1989"
  497. X.UC 4
  498. X.SH NAME
  499. macps \- print Macintosh-created PostScript file on Unix
  500. X.SH SYNOPSIS
  501. X.B macps
  502. X[
  503. X\-c copies
  504. X]
  505. X[
  506. X\-d directory
  507. X]
  508. X[
  509. X\-r
  510. X]
  511. X[
  512. file
  513. X]
  514. X.SH DESCRIPTION
  515. X.I Macps
  516. takes the command-line file (or the standard input if no filename is given),
  517. and prepends the appropriate Macintosh LaserPrep file (e.g., those generated
  518. by
  519. X.IR prepfix (1)).
  520. The standard output can then be directed to a PostScript printer, via
  521. X.IR lpr (1),
  522. for example.
  523. X.PP
  524. The input PostScript file is generated on a Macintosh by typing (and holding)
  525. Command-F immediately after clicking the OK button of the LaserWriter printer
  526. dialog box.
  527. Another dialog will appear, confirming that a file named ``PostScript'' is
  528. being created (the Command-F keys can be released now).
  529. X.PP
  530. Depending on the application, the created PostScript file can be found in the
  531. System Folder, the application folder or the top level of the disk.
  532. This file can then be uploaded via some file transfer program, such as
  533. MacTerminal/VersaTerm and
  534. X.IR macget (1)
  535. or MacKermit/Red Ryder and
  536. X.IR kermit (1).
  537. X.PP
  538. Normally, you would specify the number of copies in the LaserWriter
  539. print dialog box on the Macintosh.
  540. However, you can override that after uploading the PostScript file by
  541. specifying the
  542. X.B \-c
  543. option, followed by the number of copies.
  544. X.PP
  545. The file
  546. X.B macps.config
  547. specifies the mapping between the internal LaserPrep name and the actual
  548. file it resides in.
  549. This file is normally located in the lib subdirectory from which
  550. X.I macps
  551. was called from.
  552. The
  553. X.B \-d
  554. option allow you to specify an alternate directory in which the
  555. X.B macps.config
  556. file can be found.
  557. X.PP
  558. Most Macintosh applications produce normal ASCII PostScript files.
  559. However, some graphics programs that manipulate gray-scale images will
  560. produce PostScript files that contain 8-bit binary data.
  561. Since
  562. X.I macps
  563. normally converts this binary data, these PostScript file will not work
  564. properly.
  565. The
  566. X.B \-r
  567. X(raw) option suppresses this binary conversion.
  568. X(Note: Depending on how the printer is physically connected, it may not be
  569. able to handle 8-bit binary data properly, and results may be disappointing.)
  570. X.SH FILES
  571. X.TP "\w'lib/macps.config   'u"
  572. lib/macps.config
  573. maps ProcSet ids to LaserPrep filenames
  574. X.SH "SEE ALSO"
  575. lpr(1), macget(1), kermit(1), prepfix(1)
  576. X.SH BUGS
  577. X.I Macps
  578. only works with version 4.0 and up of the Macintosh LaserPrep files.
  579. Because of the way bit smoothing is implimented by the LaserWriter driver,
  580. some PostScript printers other than the Apple LaserWriters may not be able to
  581. bit smooth.
  582. END_OF_FILE
  583. if test 2592 -ne `wc -c <'macps.1'`; then
  584.     echo shar: \"'macps.1'\" unpacked with wrong size!
  585. fi
  586. # end of 'macps.1'
  587. fi
  588. if test -f 'macps.c' -a "${1}" != "-c" ; then 
  589.   echo shar: Will not clobber existing file \"'macps.c'\"
  590. else
  591. echo shar: Extracting \"'macps.c'\" \(5053 characters\)
  592. sed "s/^X//" >'macps.c' <<'END_OF_FILE'
  593. X/*
  594. X * Copyright (c) 1988, The Regents of the University of California.
  595. X * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  596. X * Information Systems and Technology.
  597. X *
  598. X * Permission is granted to any individual or institution to use, copy,
  599. X * or redistribute this software so long as it is not sold for profit,
  600. X * provided that this notice and the original copyright notices are
  601. X * retained.  The University of California makes no representations about the
  602. X * suitability of this software for any purpose.  It is provided "as is"
  603. X * without express or implied warranty.
  604. X */
  605. X
  606. X#ifndef lint
  607. static char *SCCSid = "@(#)macps.c    2.2 10/25/89";
  608. X#endif lint
  609. X
  610. X#include <ctype.h>
  611. X#include <stdio.h>
  612. X#ifdef SYSV
  613. X#include <string.h>
  614. X#else SYSV
  615. X#include <strings.h>
  616. X#endif SYSV
  617. X#include <sys/types.h>
  618. X#include <sys/file.h>
  619. X#include "str.h"
  620. X#include "ucbwhich.h"
  621. X
  622. X#define    CONFIG        "macps.config"
  623. X#ifdef SYSV
  624. X#define    index        strchr
  625. X#define    rindex        strrchr
  626. X#endif SYSV
  627. X
  628. X#ifdef SAVE
  629. char *finale = "clear countdictstack 2 sub{end}repeat macps restore\n";
  630. char intro[] = "\
  631. X%%! *** Created by macps: %s\
  632. X/macps save def\n\
  633. X";
  634. X#else SAVE
  635. char intro[] = "\
  636. X%%! *** Created by macps: %s\
  637. X";
  638. X#endif SAVE
  639. char *myname;
  640. int ncopies = 0;
  641. X#ifdef CONFIGDIR
  642. char ucblib[UCBMAXPATHLEN] = CONFIGDIR;
  643. X#else CONFIGDIR
  644. int ucbalternate;
  645. char ucbpath[UCBMAXPATHLEN];
  646. char ucblib[UCBMAXPATHLEN];
  647. X#endif CONFIGDIR
  648. X
  649. main(argc, argv)
  650. int argc;
  651. char **argv;
  652. X{
  653. X    register STR* str;
  654. X    register char *cp, *pp;
  655. X    register FILE *fp;
  656. X    register int i, fd;
  657. X    char line[BUFSIZ];
  658. X    char path[UCBMAXPATHLEN];
  659. X    long ltime;
  660. X    char *ctime();
  661. X
  662. X#ifndef CONFIGDIR
  663. X    ucbwhich(*argv);
  664. X#endif CONFIGDIR
  665. X    if(myname = rindex(*argv, '/'))
  666. X        myname++;
  667. X    else
  668. X        myname = *argv;
  669. X    cp = NULL;
  670. X    for(argc--, argv++ ; argc > 0 && **argv == '-' ; argc--, argv++) {
  671. X        switch((*argv)[1]) {
  672. X         case 'c':    /* multiple copies */
  673. X            if((*argv)[2])
  674. X                ncopies = atoi(&(*argv[2]));
  675. X            else {
  676. X                if(argc < 2)
  677. X                    Usage();    /* never returns */
  678. X                argc--;
  679. X                ncopies = atoi(*++argv);
  680. X            }
  681. X            if(ncopies <= 0)
  682. X                Usage();    /* never returns */
  683. X            break;
  684. X         case 'd':    /* alternate directory for config file */
  685. X            if((*argv)[2])
  686. X                cp = &(*argv[2]);
  687. X            else {
  688. X                if(argc < 2)
  689. X                    Usage();    /* never returns */
  690. X                argc--;
  691. X                cp = *++argv;
  692. X            }
  693. X            strcpy(ucblib, cp);
  694. X            break;
  695. X         case 'r':    /* raw mode */
  696. X            rawmode++;
  697. X            break;
  698. X         default:
  699. X            Usage();    /* never returns */
  700. X        }
  701. X    }
  702. X    if(argc > 1)
  703. X        Usage();    /* never returns */
  704. X    if(argc == 1 && freopen(*argv, "r", stdin) == NULL) {
  705. X        fprintf(stderr, "%s: can't open %s\n", myname, *argv);
  706. X        exit(1);
  707. X    }
  708. X    str = STRalloc();
  709. X    if(!STRgets(str, stdin)) {
  710. X        fprintf(stderr, "%s: Null input\n", myname);
  711. X        exit(1);
  712. X    }
  713. X    strcat(ucblib, "/");
  714. X    strcpy(path, ucblib);
  715. X    strcat(path, CONFIG);
  716. X    if((fp = fopen(path, "r")) == NULL) {
  717. X        fprintf(stderr, "%s: Can't open %s\n", myname, path);
  718. X        exit(1);
  719. X    }
  720. X    time(<ime);
  721. X    printf(intro, ctime(<ime));
  722. X    do {
  723. X        if(ncopies != 0 && STRheadcompare(str, "userdict /#copies ")
  724. X         == 0)
  725. X            continue;
  726. X        if(STRcompare(str, "%%EOF\n") == 0) {
  727. X#ifdef SAVE
  728. X            if(finale) {
  729. X                fputs(finale, stdout);
  730. X                finale = NULL;
  731. X            }
  732. X#endif SAVE
  733. X            STRputs(str, stdout);
  734. X            continue;
  735. X        }
  736. X        if(STRheadcompare(str, "%%IncludeProcSet:") == 0) {
  737. X            for(cp = (char *)&str->bufptr[17] ; ; cp++) {
  738. X                if(!*cp) {
  739. X                    fprintf(stderr,
  740. X                 "%s: Syntax error on IncludeProcSet line\n",
  741. X                     myname);
  742. X                    exit(1);
  743. X                }
  744. X                if(!isascii(*cp) || !isspace(*cp))
  745. X                    break;
  746. X            }
  747. X            pp = (char *)str->curendptr;
  748. X            while(--pp >= cp) {
  749. X                if(!isascii(*pp) || !isspace(*pp))
  750. X                    break;
  751. X                *pp = 0;
  752. X            }
  753. X            str->curendptr = (unsigned char *)(pp + 1);
  754. X            fseek(fp, 0L, 0);
  755. X            for( ; ; ) {
  756. X                if(!fgets(line, BUFSIZ, fp)) {
  757. X                    fprintf(stderr,
  758. X                     "%s: Unknown IncludeProcSet %s\n",
  759. X                     myname, cp);
  760. X                    exit(1);
  761. X                }
  762. X                if(*line == '#')
  763. X                    continue;
  764. X                if(pp = index(line, '\n')) {
  765. X                    if(pp == line)
  766. X                        continue;
  767. X                    *pp = 0;
  768. X                }
  769. X                if(!(pp = index(line, '\t'))) {
  770. X                    fprintf(stderr,
  771. X                     "%s: Syntax error in macps.config\n",
  772. X                     myname);
  773. X                    exit(1);
  774. X                }
  775. X                *pp++ = 0;
  776. X                if(STRcompareptr(str, cp, line) == 0)
  777. X                    break;
  778. X            }
  779. X            if(*pp == '/')
  780. X                strcpy(path, pp);
  781. X            else {
  782. X                strcpy(path, ucblib);
  783. X                strcat(path, pp);
  784. X            }
  785. X            fflush(stdout);
  786. X            if((fd = open(path, O_RDONLY, 0)) < 0) {
  787. X                fprintf(stderr, "%s: Can't open %s\n", myname,
  788. X                 path);
  789. X                exit(1);
  790. X            }
  791. X            while((i = read(fd, line, BUFSIZ)) > 0)
  792. X                write(1, line, i);
  793. X            close(fd);
  794. X            continue;
  795. X        }
  796. X        STRputs(str, stdout);
  797. X        if(ncopies > 1 && isascii(*str->bufptr) &&
  798. X         isdigit(*str->bufptr)) {
  799. X            cp = (char *)str->bufptr;
  800. X            while(cp < (char *)str->curendptr && isascii(*cp)
  801. X             && isdigit(*cp))
  802. X                cp++;
  803. X            if((char *)str->curendptr - cp == 4 &&
  804. X             STRcompareptr(str, cp, " mf\n") == 0) {
  805. X                printf("userdict /#copies %d put\n", ncopies);
  806. X                ncopies = -1;
  807. X            }
  808. X        }
  809. X    } while(STRgets(str, stdin));
  810. X#ifdef SAVE
  811. X    if(finale)
  812. X        fputs(finale, stdout);
  813. X#endif SAVE
  814. X    exit(0);
  815. X}
  816. X
  817. Usage()
  818. X{
  819. X    fputs("Usage: macps [-c #] [-d directory] [-r] [file]\n", stderr);
  820. X    exit(1);
  821. X}
  822. END_OF_FILE
  823. if test 5053 -ne `wc -c <'macps.c'`; then
  824.     echo shar: \"'macps.c'\" unpacked with wrong size!
  825. fi
  826. # end of 'macps.c'
  827. fi
  828. if test -f 'macps.config' -a "${1}" != "-c" ; then 
  829.   echo shar: Will not clobber existing file \"'macps.config'\"
  830. else
  831. echo shar: Extracting \"'macps.config'\" \(536 characters\)
  832. sed "s/^X//" >'macps.config' <<'END_OF_FILE'
  833. X# This is the config file read by macps.
  834. X# SCCSid = "@(#)macps.config    2.2 10/24/89"
  835. X#
  836. X# Each line is composed of the %%IncludeProcSet id, a tab and the file
  837. X# containing the ProcSet.  If the file doesn't begin with a slash, the
  838. X# the name is taken to be relative to the directory in which this config file
  839. X# resides.
  840. X
  841. X"(AppleDict md)" 65 0    ProcSets/LaserPrep4.0
  842. X"(AppleDict md)" 66    ProcSets/LaserPrep5.0
  843. X"(AppleDict md)" 67 0    ProcSets/LaserPrep5.1
  844. X"(AppleDict md)" 68 0    ProcSets/LaserPrep5.2
  845. X"(AppleDict md)" 70 0    ProcSets/LaserPrep6.0
  846. END_OF_FILE
  847. if test 536 -ne `wc -c <'macps.config'`; then
  848.     echo shar: \"'macps.config'\" unpacked with wrong size!
  849. fi
  850. # end of 'macps.config'
  851. fi
  852. if test -f 'prepfix.1' -a "${1}" != "-c" ; then 
  853.   echo shar: Will not clobber existing file \"'prepfix.1'\"
  854. else
  855. echo shar: Extracting \"'prepfix.1'\" \(2100 characters\)
  856. sed "s/^X//" >'prepfix.1' <<'END_OF_FILE'
  857. X.\" SCCSid = "@(#)prepfix.1    2.2 10/24/89"
  858. X.TH PREPFIX 1 "24 Oct 1989"
  859. X.UC 4
  860. X.SH NAME
  861. prepfix \- converts Apple LaserPrep files to form useable on Unix
  862. X.SH SYNOPSIS
  863. X.B prepfix
  864. X[
  865. X\-l
  866. printer_name1
  867. X[
  868. X\-l
  869. printer_name2
  870. X]...
  871. X]
  872. X[
  873. file
  874. X]
  875. X.SH DESCRIPTION
  876. X.I Prepfix
  877. takes the command-line LaserPrep file (or the standard input if no filename is
  878. given), and converts it into a form that is useable on Unix with the
  879. X.IR macps (1),
  880. and is even electronically mailable.
  881. X.PP
  882. To use
  883. X.IR prepfix ,
  884. create the input LaserPrep file on a Macintosh by opening an empty
  885. document in some application, selecting
  886. X.B Print
  887. X>From the
  888. X.B File
  889. menu and then typing (and holding) Command-K immediately after clicking the
  890. X.B OK
  891. button in the LaserWriter print dialog box.
  892. Another dialog will appear, confirming that a file named ``PostScript'' is
  893. being created (the Command-K keys can be released now).
  894. X.PP
  895. Depending on the application, the created PostScript file can be found in the
  896. System Folder, the application folder or the top level of the disk.
  897. This file can then be uploaded via some file transfer program, such as
  898. MacTerminal/VersaTerm and
  899. X.IR macget (1)
  900. or MacKermit/Red Ryder and
  901. X.IR kermit (1).
  902. X.PP
  903. Normally, only Apple LaserWriters can take advantage of the bit smoothing
  904. feature of the LaserPrep file.
  905. However, other PostScript laser printer using the Motorola 680x0 processor
  906. and the Adobe PostScript firmware can be made to do bit smoothing by
  907. specifying for each printer the
  908. X.B \-l
  909. option and the printer's name, as returned by the PostScript
  910. X.B product
  911. command in
  912. X.B statusdict
  913. X(remember to quote the printer name if it contains blanks).
  914. The resulting LaserPrep file will be modified so that for LaserWriters and for
  915. printers specified in the
  916. X.B \-l
  917. option, bit smoothing will be allowed (smoothing must still be selected in the
  918. Print Dialog box when saving the PostScript to disk).
  919. More than one printer name can be specified using additional
  920. X.B \-l
  921. and printer name pairs.
  922. X.SH "SEE ALSO"
  923. macps(1), macget(1), kermit(1)
  924. X.SH BUGS
  925. X.I Prepfix
  926. only works with version 4.0 and up of the Macintosh LaserPrep files.
  927. END_OF_FILE
  928. if test 2100 -ne `wc -c <'prepfix.1'`; then
  929.     echo shar: \"'prepfix.1'\" unpacked with wrong size!
  930. fi
  931. # end of 'prepfix.1'
  932. fi
  933. if test -f 'prepfix.c' -a "${1}" != "-c" ; then 
  934.   echo shar: Will not clobber existing file \"'prepfix.c'\"
  935. else
  936. echo shar: Extracting \"'prepfix.c'\" \(5999 characters\)
  937. sed "s/^X//" >'prepfix.c' <<'END_OF_FILE'
  938. X/*
  939. X * Copyright (c) 1988, The Regents of the University of California.
  940. X * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  941. X * Information Systems and Technology.
  942. X *
  943. X * Permission is granted to any individual or institution to use, copy,
  944. X * or redistribute this software so long as it is not sold for profit,
  945. X * provided that this notice and the original copyright notices are
  946. X * retained.  The University of California makes no representations about the
  947. X * suitability of this software for any purpose.  It is provided "as is"
  948. X * without express or implied warranty.
  949. X */
  950. X
  951. X#ifndef lint
  952. static char *SCCSid = "@(#)prepfix.c    2.2 10/25/89";
  953. X#endif lint
  954. X
  955. X#include <ctype.h>
  956. X#include <stdio.h>
  957. X#ifdef SYSV
  958. X#include <string.h>
  959. X#else SYSV
  960. X#include <strings.h>
  961. X#endif SYSV
  962. X#include "str.h"
  963. X
  964. X#define    CLEARTOMARK    12
  965. X#define EEXECLEN    80
  966. X#define EXTRA        (NZEROLINE * ZEROLINE + CLEARTOMARK)
  967. X#define LINELEN        256
  968. X#define    NPRODUCTS    32
  969. X#define NZEROLINE    7
  970. X#define ZEROLINE    65
  971. X#ifdef SYSV
  972. X#define    index        strchr
  973. X#define    rindex        strrchr
  974. X#endif SYSV
  975. X
  976. char exstr[] = "\
  977. X%ck userdict/%s known not and{currentfile eexec}{%d{currentfile read\n\
  978. pop pop}repeat}ifelse\n\
  979. X";
  980. char *match();
  981. char *myname;
  982. int maxproducts = NPRODUCTS;
  983. int nproducts = 0;
  984. char Ok[] = "\
  985. X/Ok{ok{true}{save /Pd statusdict /product get def false 0 1 ProdArr length\n\
  986. X1 sub{Pd exch ProdArr exch get anchorsearch exch pop{pop pop true exit}if}for\n\
  987. exch restore}ifelse}bind def\n\
  988. X";
  989. char ProdArr0[] = "/ProdArr [\n";
  990. char ProdArr1[] = "] def\n";
  991. char **products;
  992. char tempname[] = "/tmp/prepfixXXXXXX";
  993. X
  994. main(argc, argv)
  995. int argc;
  996. char **argv;
  997. X{
  998. X    register STR *str;
  999. X    register FILE *tp;
  1000. X    register int i;
  1001. X    register unsigned char *lp;
  1002. X    char buf[BUFSIZ];
  1003. X    char *malloc(), *realloc();
  1004. X
  1005. X    if(myname = rindex(*argv, '/'))
  1006. X        myname++;
  1007. X    else
  1008. X        myname = *argv;
  1009. X    for(argc--, argv++ ; argc > 0 && **argv == '-' ; argc--, argv++) {
  1010. X        switch((*argv)[1]) {
  1011. X         case 'h':
  1012. X            usage();
  1013. X         case 'l':
  1014. X            if(nproducts <= 0 && (products =
  1015. X             (char **)malloc(maxproducts*sizeof(char *))) == NULL) {
  1016. X                fprintf(stderr,
  1017. X                 "%s: Out of memory creating products array\n",
  1018. X                 myname);
  1019. X                exit(1);
  1020. X            } else if(nproducts >= maxproducts - 1 && (products =
  1021. X             (char **)realloc(products, (maxproducts += NPRODUCTS)
  1022. X             * sizeof(char *))) == NULL) {
  1023. X                fprintf(stderr,
  1024. X                 "%s: Out of memory expanding products array\n",
  1025. X                 myname);
  1026. X                exit(1);
  1027. X            }
  1028. X            if((*argv)[2])
  1029. X                products[nproducts++] = &(*argv)[2];
  1030. X            else {
  1031. X                if(argc < 2) {
  1032. X                    fprintf(stderr,
  1033. X                     "%s: No argument for -l\n", myname);
  1034. X                    exit(1);
  1035. X                }
  1036. X                argc--;
  1037. X                argv++;
  1038. X                products[nproducts++] = *argv;
  1039. X            }
  1040. X            break;
  1041. X        }
  1042. X    }
  1043. X    if(argc > 1)
  1044. X        usage();
  1045. X    if(argc > 0 && freopen(*argv, "r", stdin) == NULL) {
  1046. X        fprintf(stderr, "%s: Can't open %s\n", myname, *argv);
  1047. X        exit(1);
  1048. X    }
  1049. X    mktemp(tempname);
  1050. X    if((tp = fopen(tempname, "w+")) == NULL) {
  1051. X        fprintf(stderr, "%s: Can't create temp file %s\n",
  1052. X         myname, tempname);
  1053. X        exit(1);
  1054. X    }
  1055. X    unlink(tempname);
  1056. X    str = STRalloc();
  1057. X    if(!STRgets(str, stdin)) {
  1058. X        fprintf(stderr, "%s: Null input\n", myname);
  1059. X        exit(1);
  1060. X    }
  1061. X    for( ; ; ) {
  1062. X        if(STRheadcompare(str, "% \251") == 0) {
  1063. X            fputs("% ", tp);
  1064. X            str->bufptr[0] = '(';
  1065. X            str->bufptr[1] = 'C';
  1066. X            str->bufptr[2] = ')';
  1067. X        } else if(STRheadcompare(str, "%%BeginProcSet:") == 0) {
  1068. X            STRputs(str, stdout);
  1069. X            fseek(tp, 0L, 0);
  1070. X            while((i = fread(buf, 1, BUFSIZ, tp)) > 0)
  1071. X                fwrite(buf, 1, i, stdout);
  1072. X            fclose(tp);
  1073. X            break;
  1074. X        }
  1075. X        STRputs(str, tp);
  1076. X        if(!STRgets(str, stdin)) {
  1077. X            fprintf(stderr, "%s: No BeginProcSet\n", myname);
  1078. X            exit(1);
  1079. X        }
  1080. X    }
  1081. X    while(STRgets(str, stdin)) {
  1082. X        if(nproducts > 0 && STRheadcompare(str, "/ok{") == 0) {
  1083. X            STRputs(str, stdout);
  1084. X            fputs(ProdArr0, stdout);
  1085. X            for(i = 0 ; i < nproducts ; i++)
  1086. X                printf("(%s)\n", products[i]);
  1087. X            fputs(ProdArr1, stdout);
  1088. X            fputs(Ok, stdout);
  1089. X            continue;
  1090. X        } else if(STRmatch(str, "setdefaulttimeouts")
  1091. X         || STRmatch(str, "setsccinteractive"))
  1092. X            continue;
  1093. X        else if(STRmatch(str, "/stretch") && STRmatch(str, "eexec")) {
  1094. X            eexec("stretch", str);
  1095. X            continue;
  1096. X        } else if(STRmatch(str, "/smooth4") && STRmatch(str, "eexec")) {
  1097. X            eexec("smooth4", str);
  1098. X            continue;
  1099. X        } else if(STRmatch(str, " checkload")) {
  1100. X            checkload(str);
  1101. X            continue;
  1102. X        } else if(STRmatch(str, "(LaserWriter II NT)")) {
  1103. X            while(STRgets(str, stdin) && STRheadcompare(str, "35de")
  1104. X             != 0)
  1105. X                { /* ignore line */ }
  1106. X            while(STRgets(str, stdin) && isxdigit(*str->bufptr))
  1107. X                { /* ignore line */ }
  1108. X        } else if(lp = STRmatch(str, "scaleby96{ppr")) {
  1109. X            STRputsptr(str, lp, stdout);
  1110. X            continue;
  1111. X        } else if(STRmatch(str, "waittimeout"))
  1112. X            continue;
  1113. X        else if(STRheadcompare(str, "%%EndProcSet") == 0) {
  1114. X            STRputs(str, stdout);
  1115. X            break;
  1116. X        }
  1117. X        STRputs(str, stdout);
  1118. X    }
  1119. X    exit(0);
  1120. X}
  1121. X
  1122. eexec(name, str)
  1123. char *name;
  1124. register STR *str;
  1125. X{
  1126. X    register int len;
  1127. X
  1128. X    if(!STRgets(str, stdin)) {
  1129. X        fprintf(stderr, "%s: EOF during reading eexec\n", myname);
  1130. X        exit(1);
  1131. X    }
  1132. X    len = (str->curendptr - str->bufptr) - 1;
  1133. X    printf(exstr, nproducts > 0 ? 'O' : 'o', name, len + (len / EEXECLEN)
  1134. X     + (len % EEXECLEN ? 1 : 0) + EXTRA);
  1135. X    spliteexec(str);
  1136. X}
  1137. X
  1138. checkload(str)
  1139. register STR *str;
  1140. X{
  1141. X    if(nproducts > 0)
  1142. X        *str->bufptr = 'O';
  1143. X    STRputs(str, stdout);
  1144. X    if(!STRgets(str, stdin)) {
  1145. X        fprintf(stderr, "%s: EOF during reading eexec\n", myname);
  1146. X        exit(1);
  1147. X    }
  1148. X    spliteexec(str);
  1149. X}
  1150. X
  1151. spliteexec(str)
  1152. register STR *str;
  1153. X{
  1154. X    register int len;
  1155. X    register unsigned char *bp;
  1156. X
  1157. X    bp = str->bufptr;
  1158. X    len = (str->curendptr - bp) - 1;
  1159. X    while(len >= 80) {
  1160. X        fwrite(bp, 80, 1, stdout);
  1161. X        putchar('\n');
  1162. X        bp += 80;
  1163. X        len -= 80;
  1164. X    }
  1165. X    if(len > 0) {
  1166. X        fwrite(bp, len, 1, stdout);
  1167. X        putchar('\n');
  1168. X    }
  1169. X    for( ; ; ) {
  1170. X        if(!STRgets(str, stdin)) {
  1171. X            fprintf(stderr, "%s: EOF reached before cleartomark\n",
  1172. X             myname);
  1173. X            exit(1);
  1174. X        }
  1175. X        STRputs(str, stdout);
  1176. X        if(STRheadcompare(str, "cleartomark") == 0)
  1177. X            return;
  1178. X    }
  1179. X}
  1180. X
  1181. usage()
  1182. X{
  1183. X    fprintf(stderr,
  1184. X     "Usage: %s [-l product_name1 [-l product_name2]...] [file]\n",
  1185. X     myname);
  1186. X    fprintf(stderr, "       %s -help\n", myname);
  1187. X    exit(1);
  1188. X}
  1189. END_OF_FILE
  1190. if test 5999 -ne `wc -c <'prepfix.c'`; then
  1191.     echo shar: \"'prepfix.c'\" unpacked with wrong size!
  1192. fi
  1193. # end of 'prepfix.c'
  1194. fi
  1195. if test -f 'str.h' -a "${1}" != "-c" ; then 
  1196.   echo shar: Will not clobber existing file \"'str.h'\"
  1197. else
  1198. echo shar: Extracting \"'str.h'\" \(1160 characters\)
  1199. sed "s/^X//" >'str.h' <<'END_OF_FILE'
  1200. X/*
  1201. X * Copyright (c) 1988, The Regents of the University of California.
  1202. X * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  1203. X * Information Systems and Technology.
  1204. X *
  1205. X * Permission is granted to any individual or institution to use, copy,
  1206. X * or redistribute this software so long as it is not sold for profit,
  1207. X * provided that this notice and the original copyright notices are
  1208. X * retained.  The University of California makes no representations about the
  1209. X * suitability of this software for any purpose.  It is provided "as is"
  1210. X * without express or implied warranty.
  1211. X */
  1212. X
  1213. X/*
  1214. X * SCCSid = "@(#)str.h    2.2 10/24/89"
  1215. X */
  1216. X
  1217. X#define    STRSIZEDELTA    1024
  1218. X#define    STRSIZE        1024
  1219. X
  1220. X#define    STRcompare(str,fp)    STRcompareptr((str), (str)->bufptr, (fp))
  1221. X#define    STRheadcompare(str,fp)    STRheadcmpptr((str), (str)->bufptr, (fp))
  1222. X#define    STRputs(str,fp)        STRputsptr((str), (str)->bufptr, (fp))
  1223. X
  1224. typedef struct {
  1225. X    unsigned char *bufptr;
  1226. X    unsigned char *curendptr;
  1227. X    unsigned char *realendptr;
  1228. X} STR;
  1229. X
  1230. extern int rawmode;
  1231. X
  1232. STR *STRalloc();
  1233. int STRcompareptr();
  1234. int STRfree();
  1235. int STRgets();
  1236. int STRheadcmpptr();
  1237. unsigned char *STRmatch();
  1238. int STRputsptr();
  1239. END_OF_FILE
  1240. if test 1160 -ne `wc -c <'str.h'`; then
  1241.     echo shar: \"'str.h'\" unpacked with wrong size!
  1242. fi
  1243. # end of 'str.h'
  1244. fi
  1245. if test -f 'ucbwhich.c' -a "${1}" != "-c" ; then 
  1246.   echo shar: Will not clobber existing file \"'ucbwhich.c'\"
  1247. else
  1248. echo shar: Extracting \"'ucbwhich.c'\" \(3273 characters\)
  1249. sed "s/^X//" >'ucbwhich.c' <<'END_OF_FILE'
  1250. X/*
  1251. X * Copyright (c) 1988, The Regents of the University of California.
  1252. X * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  1253. X * Information Systems and Technology.
  1254. X *
  1255. X * Permission is granted to any individual or institution to use, copy,
  1256. X * or redistribute this software so long as it is not sold for profit,
  1257. X * provided that this notice and the original copyright notices are
  1258. X * retained.  The University of California makes no representations about the
  1259. X * suitability of this software for any purpose.  It is provided "as is"
  1260. X * without express or implied warranty.
  1261. X */
  1262. X
  1263. X#ifndef CONFIGDIR
  1264. X#ifndef lint
  1265. static char *SCCSid = "@(#)ucbwhich.c    2.2 10/24/89";
  1266. X#endif lint
  1267. X
  1268. X#include <stdio.h>
  1269. X#include <sys/types.h>
  1270. X#include <sys/stat.h>
  1271. X#include "ucbwhich.h"
  1272. X
  1273. X#define    F_OK        0    /* does file exist */
  1274. X#define    X_OK        1    /* is it executable by caller */
  1275. X#define    W_OK        2    /* writable by caller */
  1276. X#define    R_OK        4    /* readable by caller */
  1277. X
  1278. X#define    LIBLEN        4
  1279. X#ifdef SYSV
  1280. X#define    index        strchr
  1281. X#define    rindex        strrchr
  1282. X#endif SYSV
  1283. X
  1284. static char lib[] = "/lib";
  1285. X
  1286. char ucblib[UCBMAXPATHLEN];
  1287. int ucbalternate = 0;
  1288. char ucbpath[UCBMAXPATHLEN];
  1289. X
  1290. ucbwhich(str)
  1291. char *str;
  1292. X{
  1293. X    register char *dir, *name, *cp, *tp;
  1294. X    register int len;
  1295. X    char dirbuf[UCBMAXPATHLEN], namebuf[UCBMAXPATHLEN];
  1296. X    struct stat sbuf;
  1297. X    char *index(), *rindex(), *getwd(), *getenv();
  1298. X
  1299. X    strcpy(name = namebuf, str);
  1300. X    if(*name == '/')    /* absolute pathname */
  1301. X        *(rindex(dir = name, '/')) = 0 ; /* remove tail */
  1302. X    else {
  1303. X        if(cp = index(name, '/')) { /* relative pathname */
  1304. X            if((dir = getwd(dirbuf)) == NULL)
  1305. X                return(0);
  1306. X             /* if any errors occurs assume standard version */
  1307. X            *cp++ = 0;
  1308. X            for( ; ; ) {
  1309. X                if(*name != 0) { /* multiple slashes */
  1310. X                    if(strcmp(name, "..") == 0) {
  1311. X                        /* parent directory */
  1312. X                        if((tp = rindex(dir, '/')) ==
  1313. X                         NULL)
  1314. X                             return(0);
  1315. X                        if(tp == dir)
  1316. X                            tp++;
  1317. X                         /* root directory */
  1318. X                        *tp = 0;
  1319. X                         /* remove last component */
  1320. X                    } else if(strcmp(name, ".") != 0) {
  1321. X                        /* subdirectory */
  1322. X                        strcat(dir, "/");
  1323. X                        strcat(dir, name);
  1324. X                    }
  1325. X                }
  1326. X                name = cp;
  1327. X                if((cp = index(name, '/')) == NULL) break;
  1328. X                /* ignore last component */
  1329. X                *cp++ = 0;
  1330. X            }
  1331. X        } else { /* look through $PATH variable */
  1332. X            if((tp = getenv("PATH")) == NULL)
  1333. X                return(0);
  1334. X            for(name = namebuf ; ; ) {
  1335. X                if(*tp == 0)
  1336. X                    return(0);
  1337. X                else if(*tp == ':')
  1338. X                    tp++;
  1339. X                if((cp = index(tp, ':')) == NULL)
  1340. X                    cp = tp + strlen(tp);
  1341. X                 /* positioned on null */
  1342. X                for(dir = dirbuf ; tp < cp ; )
  1343. X                    *dir++ = *tp++;
  1344. X                *dir = 0;
  1345. X                strcpy(name, dir = dirbuf);
  1346. X                strcat(name, "/");
  1347. X                strcat(name, str);
  1348. X                if(stat(name, &sbuf) < 0 || (sbuf.st_mode &
  1349. X                 S_IFMT) != S_IFREG)
  1350. X                    continue;
  1351. X                if(access(name, X_OK) == 0) {
  1352. X                    if(strcmp(dir, ".") == 0 &&
  1353. X                     (dir = getwd(dirbuf)) == NULL)
  1354. X                        return(0);
  1355. X                    break;
  1356. X                }
  1357. X            }
  1358. X        }
  1359. X    }
  1360. X    strcpy(ucbpath, dir);
  1361. X    strcpy(ucblib, dir);
  1362. X    if((len = strlen(dir)) < LIBLEN || strcmp(&dir[len - LIBLEN], lib)
  1363. X     != 0)
  1364. X        strcat(ucblib, lib);
  1365. X    else
  1366. X        ucbpath[len - LIBLEN] = 0;
  1367. X    ucbalternate = (strcmp(ucbpath, UCBSTANDARD) != 0);
  1368. X#ifdef EBUG
  1369. X    fprintf(stderr, "ucbwhich: alt=%d path=%s lib=%s\n", ucbalternate,
  1370. X     ucbpath, ucblib);
  1371. X#endif EBUG
  1372. X    return(ucbalternate);
  1373. X}
  1374. X#endif CONFIGDIR
  1375. END_OF_FILE
  1376. if test 3273 -ne `wc -c <'ucbwhich.c'`; then
  1377.     echo shar: \"'ucbwhich.c'\" unpacked with wrong size!
  1378. fi
  1379. # end of 'ucbwhich.c'
  1380. fi
  1381. if test -f 'ucbwhich.h' -a "${1}" != "-c" ; then 
  1382.   echo shar: Will not clobber existing file \"'ucbwhich.h'\"
  1383. else
  1384. echo shar: Extracting \"'ucbwhich.h'\" \(778 characters\)
  1385. sed "s/^X//" >'ucbwhich.h' <<'END_OF_FILE'
  1386. X/*
  1387. X * Copyright (c) 1988, The Regents of the University of California.
  1388. X * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  1389. X * Information Systems and Technology.
  1390. X *
  1391. X * Permission is granted to any individual or institution to use, copy,
  1392. X * or redistribute this software so long as it is not sold for profit,
  1393. X * provided that this notice and the original copyright notices are
  1394. X * retained.  The University of California makes no representations about the
  1395. X * suitability of this software for any purpose.  It is provided "as is"
  1396. X * without express or implied warranty.
  1397. X */
  1398. X
  1399. X/*
  1400. X * SCCSid = "@(#)ucbwhich.h    2.2 10/24/89"
  1401. X */
  1402. X
  1403. X#define    UCBMAXPATHLEN    128
  1404. X#define    UCBSTANDARD    "/usr/ucb"
  1405. X
  1406. extern char ucblib[];
  1407. extern int ucbalternate;
  1408. extern char ucbpath[];
  1409. END_OF_FILE
  1410. if test 778 -ne `wc -c <'ucbwhich.h'`; then
  1411.     echo shar: \"'ucbwhich.h'\" unpacked with wrong size!
  1412. fi
  1413. # end of 'ucbwhich.h'
  1414. fi
  1415. echo shar: End of archive 1 \(of 1\).
  1416. cp /dev/null ark1isdone
  1417. MISSING=""
  1418. for I in 1 ; do
  1419.     if test ! -f ark${I}isdone ; then
  1420.     MISSING="${MISSING} ${I}"
  1421.     fi
  1422. done
  1423. if test "${MISSING}" = "" ; then
  1424.     echo You have the archive.
  1425.     rm -f ark[1-9]isdone
  1426. else
  1427.     echo You still need to unpack the following archives:
  1428.     echo "        " ${MISSING}
  1429. fi
  1430. ##  End of shell archive.
  1431. exit 0
  1432.